/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Dialog_Xem_ChinhSuaFile.java
 *
 * Created on Apr 9, 2009, 10:14:10 PM
 */

package QuanLyFile;

import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;

/**
 * hiện thị dialog cho phép xem dữ liệu bên trong file
 * @author Administrator
 */
public class Dialog_Xem_ChinhSuaFile extends javax.swing.JFrame {

    /** Creates new form Dialog_Xem_ChinhSuaFile */
    public Dialog_Xem_ChinhSuaFile() {
        initComponents();
        this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane_HienThiFile = new javax.swing.JScrollPane();
        jTextPane_HienThiFile = new javax.swing.JTextPane();
        jButton_Luu = new javax.swing.JButton();
        jButton_Thoat = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem_Luu = new javax.swing.JMenuItem();
        jMenuItem_Thoat = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setName("Form"); // NOI18N

        jScrollPane_HienThiFile.setName("jScrollPane_HienThiFile"); // NOI18N

        jTextPane_HienThiFile.setName("jTextPane_HienThiFile"); // NOI18N
        jTextPane_HienThiFile.setNextFocusableComponent(jButton_Luu);
        jScrollPane_HienThiFile.setViewportView(jTextPane_HienThiFile);

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(doan_totalcommander_002.DoAn_TatalCommande_002App.class).getContext().getResourceMap(Dialog_Xem_ChinhSuaFile.class);
        jButton_Luu.setText(resourceMap.getString("jButton_Luu.text")); // NOI18N
        jButton_Luu.setName("jButton_Luu"); // NOI18N
        jButton_Luu.setNextFocusableComponent(jButton_Thoat);
        jButton_Luu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_LuuActionPerformed(evt);
            }
        });

        jButton_Thoat.setText(resourceMap.getString("jButton_Thoat.text")); // NOI18N
        jButton_Thoat.setName("jButton_Thoat"); // NOI18N
        jButton_Thoat.setNextFocusableComponent(jTextPane_HienThiFile);
        jButton_Thoat.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_ThoatActionPerformed(evt);
            }
        });

        jMenuBar1.setName("jMenuBar1"); // NOI18N

        jMenu1.setText(resourceMap.getString("jMenu1.text")); // NOI18N
        jMenu1.setName("jMenu1"); // NOI18N

        jMenuItem_Luu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem_Luu.setText(resourceMap.getString("jMenuItem_Luu.text")); // NOI18N
        jMenuItem_Luu.setName("jMenuItem_Luu"); // NOI18N
        jMenuItem_Luu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem_LuuActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem_Luu);

        jMenuItem_Thoat.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F4, java.awt.event.InputEvent.ALT_MASK));
        jMenuItem_Thoat.setText(resourceMap.getString("jMenuItem_Thoat.text")); // NOI18N
        jMenuItem_Thoat.setName("jMenuItem_Thoat"); // NOI18N
        jMenuItem_Thoat.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem_ThoatActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem_Thoat);

        jMenuBar1.add(jMenu1);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(475, Short.MAX_VALUE)
                .addComponent(jButton_Luu, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jButton_Thoat)
                .addContainerGap())
            .addComponent(jScrollPane_HienThiFile, javax.swing.GroupLayout.DEFAULT_SIZE, 624, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(jScrollPane_HienThiFile, javax.swing.GroupLayout.DEFAULT_SIZE, 418, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton_Luu)
                    .addComponent(jButton_Thoat))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    
    private void jButton_LuuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_LuuActionPerformed
        // TODO add your handling code here
        //Xác nhận lưu
        if (JOptionPane.showConfirmDialog(null, "Bạn muốn lưu thay đổi?"
                , "Xác nhận lưu", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)
            try {
                BoQuanLyFile.ghiFile(getTitle(), jTextPane_HienThiFile.getText());
                JOptionPane.showMessageDialog(null, "Lưu file thành công");
            } catch (IOException ex) {
                Logger.getLogger(Dialog_Xem_ChinhSuaFile.class.getName()).log(Level.SEVERE, null, ex);
                JOptionPane.showMessageDialog(null, "Không thể ghi file " + getTitle());
            }
        
}//GEN-LAST:event_jButton_LuuActionPerformed

    private void jButton_ThoatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_ThoatActionPerformed
        // TODO add your handling code here:
        //Xác nhận thoát
        if (JOptionPane.showConfirmDialog(null, "Bạn muốn thoát?"
                , "Xác nhận thoát", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)
        dispose();
    }//GEN-LAST:event_jButton_ThoatActionPerformed

    private void jMenuItem_ThoatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_ThoatActionPerformed
        // TODO add your handling code here:
        jButton_ThoatActionPerformed(evt);
}//GEN-LAST:event_jMenuItem_ThoatActionPerformed

    private void jMenuItem_LuuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_LuuActionPerformed
        // TODO add your handling code here:
        jButton_LuuActionPerformed(evt);
    }//GEN-LAST:event_jMenuItem_LuuActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Dialog_Xem_ChinhSuaFile().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton_Luu;
    private javax.swing.JButton jButton_Thoat;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem_Luu;
    private javax.swing.JMenuItem jMenuItem_Thoat;
    private javax.swing.JScrollPane jScrollPane_HienThiFile;
    private javax.swing.JTextPane jTextPane_HienThiFile;
    // End of variables declaration//GEN-END:variables


    public JScrollPane getjScrollPane_HienThiFile(){
            return getJScrollPane_HienThiFile();
    }
    public void setjScrollPane_HienThiFile(JScrollPane jScrollPane){
            setJScrollPane_HienThiFile(jScrollPane);
    }

    /**
     * @return the jButton_Huy
     */
    public javax.swing.JButton getJButton_Huy() {
        return getJButton_Thoat();
    }

    /**
     * @param jButton_Huy the jButton_Huy to set
     */
    public void setJButton_Huy(javax.swing.JButton jButton_Huy) {
        this.setJButton_Thoat(jButton_Huy);
    }

    /**
     * @return the jButton_Luu
     */
    public javax.swing.JButton getJButton_Luu() {
        return jButton_Luu;
    }

    /**
     * @param jButton_Luu the jButton_Luu to set
     */
    public void setJButton_Luu(javax.swing.JButton jButton_Luu) {
        this.jButton_Luu = jButton_Luu;
    }

    /**
     * @return the jScrollPane_HienThiFile
     */
    public javax.swing.JScrollPane getJScrollPane_HienThiFile() {
        return jScrollPane_HienThiFile;
    }

    /**
     * @param jScrollPane_HienThiFile the jScrollPane_HienThiFile to set
     */
    public void setJScrollPane_HienThiFile(javax.swing.JScrollPane jScrollPane_HienThiFile) {
        this.jScrollPane_HienThiFile = jScrollPane_HienThiFile;
    }

    /**
     * @return the jButton_Thoat
     */
    public javax.swing.JButton getJButton_Thoat() {
        return jButton_Thoat;
    }

    /**
     * @param jButton_Thoat the jButton_Thoat to set
     */
    public void setJButton_Thoat(javax.swing.JButton jButton_Thoat) {
        this.jButton_Thoat = jButton_Thoat;
    }

    /**
     * @return the jTextPane_HienThiFile
     */
    public javax.swing.JTextPane getJTextPane_HienThiFile() {
        return jTextPane_HienThiFile;
    }

    /**
     * @param jTextPane_HienThiFile the jTextPane_HienThiFile to set
     */
    public void setJTextPane_HienThiFile(javax.swing.JTextPane jTextPane_HienThiFile) {
        this.jTextPane_HienThiFile = jTextPane_HienThiFile;
    }
}
